package com.example.util;

import java.util.Collections;
import java.util.List;

import com.baomidou.mybatisplus.core.metadata.IPage;

public class Pager<T> {

	private List<T> rows = Collections.emptyList();

	/**
	 * 总条数
	 */
	private long total;
	private long count;

	/**
	 * 每页显示多少条
	 */
	private long pageSize;
	private long limit;

	/**
	 * 总页数
	 */
	private long totalPage;
	/**
	 * 当前页
	 */
	private long currentIndex;
	private long page;

	/**
	 * 查询条件
	 */
	private String where;

	public Pager() {

	}

	public Pager(IPage<T> page) {
		this.rows = page.getRecords();
		this.total = this.rows.size();
		this.currentIndex = page.getCurrent();
		this.pageSize = page.getSize();
		this.totalPage = page.getPages();

		this.page = page.getCurrent();
		this.limit = page.getSize();
		this.count = this.rows.size();

	}

	public List<T> getRows() {
		return rows;
	}

	public long getTotal() {
		return total;
	}

	public long getPageSize() {
		return pageSize;
	}

	public long getTotalPage() {
		return totalPage;
	}

	public long getCurrentIndex() {
		return currentIndex;
	}

	public Pager<T> setRows(List<T> rows) {
		this.rows = rows;
		return this;
	}

	public Pager<T> setTotal(long total) {
		this.total = total;
		return this;
	}

	public Pager<T> setPageSize(long pageSize) {
		this.pageSize = pageSize;
		return this;
	}

	public Pager<T> setTotalPage(long totalPage) {
		this.totalPage = totalPage;
		return this;
	}

	public Pager<T> setCurrentIndex(long currentIndex) {
		this.currentIndex = currentIndex;
		return this;
	}

	public long getLimit() {
		return limit;
	}

	public Pager<T> setLimit(long limit) {
		this.limit = limit;
		return this;
	}

	public long getPage() {
		return page;
	}

	public Pager<T> setPage(long page) {
		this.page = page;
		return this;
	}

	public long getCount() {
		return count;
	}

	public Pager<T> setCount(long count) {
		this.count = count;
		return this;
	}

	public String getWhere() {
		return where;
	}

	public void setWhere(String where) {
		this.where = where;
	}

}
